#region License

// This file is part of Grawlix.
// 
// Grawlix is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// Grawlix is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public
// License along with Grawlix.  If not, see
// <http://www.gnu.org/licenses/>.

#endregion

using System;
using System.Drawing;

namespace Grawlix.Services.Rendering
{
	/// <summary>
	/// The font state information for a loaded font.
	/// </summary>
	[Serializable]
	internal sealed class GLFontState : IFontState
	{
		/// <summary>
		/// The original font loaded.
		/// </summary>
		private readonly Font _target;

		/// <summary>
		/// Whether the font has been unloaded.
		/// </summary>
		private bool _disposed;

		/// <summary>
		/// Initializes a new instance of the 
		/// <see cref="GLFontState"/> class.
		/// </summary>
		/// <param name="font">The font to load.</param>
		/// <exception cref="ArgumentNullException"><c>font</c> is
		/// null.</exception>
		public GLFontState(Font font)
		{
			if (font == null)
				throw new ArgumentNullException("font");
			_target = font;
		}

		/// <summary>
		/// Gets the original font used to create the state.
		/// </summary>
		/// <value>The original font used to create the state.</value>
		public Font Target
		{
			get { return _target; }
		}

		/// <summary>
		/// Unloads the font state.
		/// </summary>
		/// <exception cref="ObjectDisposedException">The object has
		/// already been disposed of.</exception>
		internal void Unload()
		{
			if (_disposed)
				throw new ObjectDisposedException("GLFontState");
			_disposed = true;
		}
	}
}